<%@ page language="java" %>

<%@ page import="java.util.*,
                 java.net.*,
                 java.lang.*,
                 com.broadvision.web.util.ViewDynaBean,
		 org.apache.struts.validator.DynaValidatorForm,
                 org.apache.commons.beanutils.PropertyUtils"
%>

<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 

<jsp:useBean id="cmProcessMapView" scope="request" type="com.broadvision.web.util.ViewDynaBean"/> 

<script language="javascript" src="<%=request.getContextPath()%>/mt/js/userPopup.js"></script>
<script language="javascript">

function onSubmit(myform) {
  if (myform.documentType.value == "") {
    alert("<bean:message bundle='cm.messages' key='cm.content.processMap.missingDocType'/>");
    return false;
  }
  if (myform.actionName.value == "") {
    alert("<bean:message bundle='cm.messages' key='cm.content.processMap.missingActionName'/>");
    return false;
  }
  if (myform.processPack.value == "") {
    alert("<bean:message bundle='cm.messages' key='cm.content.processMap.missingProcessPack'/>");
    return false;
  }
  if (myform.processName.value == "") {
    alert("<bean:message bundle='cm.messages' key='cm.content.processMap.missingProcessName'/>");
    return false;
  }
  myform.submit();
  return true;
}

function setProcessPack(formName, fieldName, fieldValue) {
  // this page does not have any hidden fields that rely on the popup,
  // we do not need a refresh url.
  var refreshUrl = null;
  setFieldValue(refreshUrl, formName, 'processPack', fieldValue);
}

function setProcessName(formName, fieldName, fieldValue) {
  // this page does not have any hidden fields that rely on the popup,
  // we do not need a refresh url.
  var refreshUrl = null;
  setFieldValue(refreshUrl, formName, 'processName', fieldValue);
}

function setDocType(formName, fieldName, fieldValue) {
  // this page does not have any hidden fields that rely on the popup,
  // we do not need a refresh url.
  var refreshUrl = null;
  setFieldValueSimple(formName, fieldName, fieldValue);
}

function setDocTypeFName(formName, fieldName, fieldValue) {
  // this page does not have any hidden fields that rely on the popup,
  // we do not need a refresh url.
  var refreshUrl = null;
  setFieldValue(refreshUrl, formName, "documentTypeFName", fieldValue);
}

function doCancel(theForm) {
  if (theForm != null) {
    theForm.action = '<html:rewrite page="/cm/processMapSearch.do"/>';
    theForm.submit();
    return true;
  }
  return false;
}

</script>

<html:form action="/cm/processMapSave">
<html:hidden property="cpAction"/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle='cm.messages' key='cm.content.processMap.create'/>">
  <tr> 
  <td valign="top" width="100%">
		  
  <div class="pageTitle">
    <logic:equal name="cmProcessMapView" property="action" value="edit">
      <bean:message bundle='cm.messages' key='cm.content.processMap.edit'/>
    </logic:equal>
    <logic:notEqual name="cmProcessMapView" property="action" value="edit">
      <bean:message bundle='cm.messages' key='cm.content.processMap.create'/>
    </logic:notEqual>
  </div>
  <div class="errorMessage"><html:errors bundle='cm.messages'/></div>

  <%@include file="/mc/common/pagetab.jsp" %>

  <div class="pageSubtitle">
    <span class="left"><bean:message bundle='cm.messages' key='cm.content.processMap.details'/></span>
    <span class="right">&nbsp;</span>
  </div> 
           
  <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle='cm.messages' key='cm.content.processMap.create'/>">
         
    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle='cm.messages' key='cm.content.processMap.documentType'/>*: </td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <logic:equal name="cmProcessMapView" property="action" value="edit">
          <html:hidden name="cmProcessMapView" property="documentType"/>
          <html:hidden name="cmProcessMapView" property="documentTypeFName"/>
          <bean:write name="cmProcessMapView" property="documentTypeFName" />
        </logic:equal>
        <logic:notEqual name="cmProcessMapView" property="action" value="edit">
          <html:text name="cmProcessMapView" property="documentTypeFName" maxlength="80" size="31" readonly="true"/>
          <html:hidden name="cmProcessMapView" property="documentType" />
          <input type="button" name="browseDocType" class="pageButton"
            onClick="JavaScript:findDocTypePopup('<html:rewrite page="/cm/docTypeSearchPopup.do" />?action=popup', 'cmContentProcessMapEditForm', 'documentType')"
            value='<bean:message bundle='cm.messages' key='button.browse'/>'>
        </logic:notEqual>
      </td>
    </tr>
        
    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle='cm.messages' key='cm.content.processMap.actionName'/>*: </td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <logic:equal name="cmProcessMapView" property="action" value="edit">
          <html:hidden name="cmProcessMapView" property="actionName"/>
          <html:hidden name="cmProcessMapView" property="actionFName"/>
          <bean:write name="cmProcessMapView" property="actionFName" />
        </logic:equal>
        <logic:notEqual name="cmProcessMapView" property="action" value="edit">
          <html:select name ="cmProcessMapView" property="actionName" size="1">
            <html:option value=""></html:option>
            <html:option value="Create"><bean:message bundle='cm.messages' key='cm.content.processMap.action.create'/></html:option>
            <html:option value="Edit"><bean:message bundle='cm.messages' key='cm.content.processMap.action.edit'/></html:option>
            <html:option value="Review"><bean:message bundle='cm.messages' key='cm.content.processMap.action.review'/></html:option>
            <html:option value="View"><bean:message bundle='cm.messages' key='cm.content.processMap.action.view'/></html:option>
            <html:option value="Delete"><bean:message bundle='cm.messages' key='cm.content.processMap.action.delete'/></html:option>
          </html:select>
        </logic:notEqual>
      </td>
    </tr>
        
    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle='cm.messages' key='cm.content.processMap.processPack'/>*: </td>
      <td valign="top" class="labelField" width="80%" colspan="2">
          <html:text name="cmProcessMapView" property="processPack" maxlength="80" size="31" readonly="true" />
          <input type="hidden" name="oldProcessPack" value='<bean:write name="cmProcessMapView" property="processPack"/>' />
          <input type="button" name="browseProcessPack" class="pageButton"
            onClick="JavaScript:findProcessPopup('<html:rewrite page="/cm/processSearchPopup.do" />', 'cmContentProcessMapEditForm', 'processPack')"
            value='<bean:message bundle='cm.messages' key='button.browse'/>'>
      </td>
    </tr>
        
    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle='cm.messages' key='cm.content.processMap.processName'/>*: </td>
      <td valign="top" class="labelField" width="80%" colspan="2">
          <html:text name="cmProcessMapView" property="processName" maxlength="80" size="31" readonly="true" />
          <input type="hidden" name="oldProcessName" value='<bean:write name="cmProcessMapView" property="processName"/>' />
          <input type="button" name="browseProcessName" class="pageButton"
            onClick="JavaScript:findProcessPopup('<html:rewrite page="/cm/processSearchPopup.do" />', 'cmContentProcessMapEditForm', 'processName')"
            value='<bean:message bundle='cm.messages' key='button.browse'/>'>
      </td>
    </tr>
        
  </table>
  <div class="pageButtonWrap" align="right">
    <html:reset styleClass="inputButton" property="resetBtn">
      <bean:message bundle='cm.messages' key="button.reset"/>
    </html:reset>
    &nbsp;&nbsp;
    <html:button styleClass="inputButton" property="cancelBtn" onclick="return doCancel(this.form)">
      <bean:message bundle='cm.messages' key="button.cancel"/>
    </html:button>
    <html:button styleClass="inputButton" property="submitBtn" onclick="return onSubmit(this.form)">
      <bean:message bundle='cm.messages' key="button.save"/>
    </html:button>

  </div>  
      
  <br>

 </td>
 </tr>

</table>
</html:form>
